home *** CD-ROM | disk | FTP | other *** search
- program TstSort;
-
- {$apptype console}
-
- uses
- Windows,
- AASorter in 'AASorter.pas';
-
- procedure InitRandom(var MyRec : shortstring);
- var
- i : integer;
- begin
- MyRec[0] := #15;
- for i := 1 to 15 do
- MyRec[i] := char(Random(26) + ord('A'));
- end;
-
- function MyCompare(const aItem1, aItem2 : pointer) : integer;
- var
- Item1 : ^ShortString;
- Item2 : ^ShortString;
- begin
- Item1 := aItem1;
- Item2 := aItem2;
- if (Item1^ < Item2^) then
- Result := -1
- else if (Item1^ = Item2^) then
- Result := 0
- else
- Result := 1;
- end;
-
- var
- Sorter : TaaSorter;
- PrevRec, MyRec : string[15];
- i : integer;
- begin
- writeln('Starting test');
- Sorter := TaaSorter.Create;
- try
- Sorter.MaxRecordCount := 1000;
- Sorter.RecordLength := 16;
- Sorter.Compare := MyCompare;
- for i := 1 to 10000 do begin
- InitRandom(MyRec);
- Sorter.Add(MyRec);
- end;
-
- PrevRec := '';
- while Sorter.Get(MyRec) do begin
- // writeln(MyRec);
- if (MyRec < Prevrec) then begin
- writeln('Error: out of sequence');
- readln;
- end;
- PrevRec := MyRec;
- end;
- finally
- Sorter.Free;
- end;
- writeln('Completed test');
- readln;
- end.
-